{include file=member.header.html}
<script type="text/javascript" src="{lib file=abouts_kuaidi.js}" charset="utf-8"></script>
<style type="text/css">
.text { width:250px; height:20px;line-height:20px; padding:3px; border:1px #CCC solid;  border-radius:2px;}
.eject_con .add li { width: 100%; overflow: hidden; float: left; padding-bottom: 10px; }
.eject_con .add li h3 {font-size:13px;}
</style>
<div class="content_color">
<div class="content">
{include file=member.menu.html}
<div id="right">
{include file=member.submenu.html}
<div class="wrap">

<div class="eject_con">
<div class="add">
  <div id="warning"></div>
  <form method="post" action="index.php?app=my_address&act={$act}&addr_id={$address.addr_id}" id="address_form">
  <ul>
      <li>
          <h3>选择类型：</h3>
      <p><select name="ddl_type" id="ddl_type" class="select_class">
                <option value="1" {if $address.ddl_type neq '2'}selected="selected"{/if}>收货人地址</option>
                <option value="2" {if $address.ddl_type eq '2'}selected="selected"{/if}>发货人地址</option>
              </select>
        </p>
      </li>    
    <li>
          <h3><em>*</em>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</h3>
          <p><input type="text" class="text width_normal" name="consignee" value="{$address.consignee|escape}"/><label class="field_message"><span class="field_notice">{$lang.consignee_desc}</span></label></p>
      </li>
      <li>
          <h3><em>*</em>手机电话：</h3>
          <p><input type="text" class="text width_normal" name="phone_mob" value="{$address.phone_mob}"/><label class="field_message"><span class="field_notice">请输入手机号码或者电话号码</span></label></p>
      </li>
      <!--{if $smarty.get.act eq 'has_hide'}-->
      <li style="display:none">
          <h3>{$lang.phone_tel}：</h3>
          <p><input type="text" class="text width_normal"  name="phone_tel" value="{$address.phone_tel}"/><label class="field_message"><span class="field_notice">{$lang.phone_format}</span></label></p>
      </li>
      <li>
          <h3><em>*</em>{$lang.region}：</h3>
          <p><div id="region">
              <input type="hidden" name="region_id" value="{$address.region_id}" id="region_id" class="mls_id" />
              <input type="hidden" name="region_name" value="{$address.region_name|escape}" class="mls_names" />
              <!-- {if $address.region_id} -->
              <span>{$address.region_name|escape}</span>
              <input type="button" value="{$lang.edit}" class="edit_region" />
              <select style="display:none" onchange="hide_error();">
                <option>{$lang.select_pls}</option>
                {html_options options=$regions}
              </select>
              <!-- {else} -->
              <select onchange="hide_error();">
                <option>{$lang.select_pls}</option>
                {html_options options=$regions}
              </select>
              <!-- {/if} -->
              <b class="field_message" style="font-weight:normal;"><label class="field_notice"></label></b>
            </div></p>
      </li>
      <!-- {/if} -->
      <li>
          <h3><em>*</em>国&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;家：</h3>
          <p><input type="text" class="text width_normal" name="txt_country" id="txt_country" value="{$address.txt_country|escape}"/><label class="field_message"></label></p>
      </li>
      <li>
          <h3><em>*</em>选择地区：</h3>
          <p><input name="txt_province" type="text" id="txt_province" class="text" style="width:80px;" value="{$address.txt_province}"/> 省/州&nbsp;
          <input name="txt_city" type="text" id="txt_city" class="text" style="width:80px;" value="{$address.txt_city}"/> 市&nbsp;
          <div id="divQu" style="display:{if $address.ddl_type eq '2'}none{else}inline{/if}"><input name="txtqu" type="text" id="txtqu" class="text" style="width:60px;"  value="{$address.txtqu}"//> 区/县</div>
          &nbsp;<font color="#FF0000">*必填项</font>
          </p>
      </li>                  
    <li>
          <h3><em>*</em>{$lang.address}：</h3>
          <p><input type="text" class="text width10" name="address" value="{$address.address|escape}"/><label class="field_message"><span class="field_notice">{$lang.address_desc}</span></label></p>
      </li>  
      <li>
          <h3><em>*</em>{$lang.zipcode}：</h3>
          <p><input type="text" class="text width10" name="zipcode" id="zipcode" value="{$address.zipcode|escape}"/><label class="field_message"><span class="field_notice">{$lang.zipcode_desc}</span></label></p>
      </li>  
       
      <li>
          <h3>邮箱地址：</h3>
          <p><input name="txt_email" type="text" id="txt_email" class="text" placeholder="Email地址" value="{$address.txt_email}"/><label class="field_message"></label></p>
      </li>  
      <li>
          <h3>公司名称：</h3>
          <p><input name="txt_company" type="text" id="txt_company" class="text" value="{$address.txt_company}"/></p>
      </li>                                                
      <li>
          <h3>身份证类别：</h3>
          <p><label><input id="idpic" type="radio" name="idpic" value="rbtnyes" {if $address.idpic neq 'rbtnno'}checked="checked"{/if}/> 大陆地区</label>&nbsp;&nbsp;
          <label><input id="idpic" type="radio" name="idpic" value="rbtnno" {if $address.idpic eq 'rbtnno'}checked="checked"{/if}/> 非大陆地区</label>            
          </p>
      </li>    
      <li>
          <h3><em>*</em>身份证号码：</h3>
          <p><input name="txtidcode" type="text" id="txtidcode" size="50" class="text" placeholder="身份证号码必填方便清关" value="{$address.txtidcode}"/><label class="field_message"></label></p>
      </li>
      <li>
          <h3>身份证上传：</h3>
          <p>
           <div style="width:380px; float:left">
           <input name="c_input" type="hidden" id="c_input" />
              <input id="btnZM" onclick="UploadCard('c_input','c_img')" class="lcj_btn" type="button" value="上传正面" style="margin-left:0"/>&nbsp;
              <img align="absmiddle" id="c_img" style="width:80px;" />
              <input name="c_input2" type="hidden" id="c_input2" />
              <input id="btnFM" onclick="UploadCard('c_input2','c_img2')" class="lcj_btn" type="button" value="上传反面" />&nbsp;
              <img align="absmiddle" id="c_img2" style="width:80px;" />
              <input name="id_photo" type="hidden" value="{$address.id_photo}"/>
              <!--{if $address.id_photo}--><br />
              <a href="data/files/mall/idphoto/{$address.id_photo}" target="_blank" title="已上传身份证照片"><img src="data/files/mall/idphoto/{$address.id_photo}" height="80"/>已上传身份证照片</a>
              <!--{/if}-->
            </div>
            <div style="color:#666; font-size:12px;float:left">
            怎么上传符合网站要求的照片呢？<br />
            1、宽度和高度建议像素300*300 不能大于<b>&nbsp;512kb</b><br />
            2、建议使用二代身份证。<br />
            3、照片需免冠，建议未化妆。<br />
            4、照片支持jpg、jpeg、bmp格式，无大小限制。<br />
            5、照片需原始图片未经任何软件编辑修改。<br />
            6、您提供的照片信息道达快递予以保护，不会挪作他用
            </div>
          </p>
      </li> 
  </ul>
  <div class="submit"><input type="submit" class="submit_btn" value="<!--{if $address.addr_id}-->{$lang.edit_address}<!--{else}-->{$lang.add_address}<!--{/if}-->" /></div>
  </form>
</div>
</div>
</div>

</div></div></div>
<script type="text/javascript">
$(function(){
    //regionInit("region");
	$(".submit_btn").click(function(){
		return checkTelEnglish();	
		$('#address_form').validate({
			errorPlacement: function(error, element){
				var _message_box = $(element).parent().find('.field_message');
				_message_box.find('.field_notice').hide();
				_message_box.append(error);
			},
			success : function(label){
				label.addClass('validate_right').text('OK!');
			},
			onkeyup : false,
			rules : {
				consignee : {required : true },
				//phone_mob : {required : true, checkTelEnglish:true},
				//phone_tel : {required : check_phone, minlength:6, checkTel:true },
				//region_id : {required : true,min   : 1 },
				txt_country : {required : true },
				txt_province : {required : true },
				txt_city : {required : true },
				txtqu : {required : check_txtqu },
				address   : {required : true },
				zipcode : {required : true, digits : true },
				txt_email : { email : true },
				txtidcode : {required : true, checkIdcard:true }
			},
			messages : {
				consignee : {required : '请填写姓名. ' },
				//phone_mob : {required : '请填写正确的手机电话号码. ', checkTelEnglish: '格式有误，请输入10-13位的号码，且只能输入数字或者-横线. '},
				//phone_tel : {required : '{$lang.phone_required}. ', minlength: '{$lang.phone_tel_error}. ',checkTel: '{$lang.phone_tel_error}. ' },
				//region_id : {required : '{$lang.region_required}. ', min  : '{$lang.region_required}. ' },
				txt_country : {required : '请填写国家. ' },
				txt_province : {required : '请填写省或州. ' },
				txt_city : {required : '请填写城市. ' },
				txtqu : {required : '请填写区或县. ' },
				address   : {required : '{$lang.address_required}. ' },
				zipcode : {required : '请填写邮政编码. ' , digits : '邮政编码必须为数字'},
				txt_email : { email : '邮箱地址格式有误，请正确输入' },
				txtidcode : {required : '请填写有效的身份证号码. ', checkIdcard:'错误格式的身份证号码，请输入有效的身份证号码' }
			}
		});
    });		
	$('#ddl_type').change(function(){ 
		var select_val = $(this).children('option:selected').val(); 
		if(select_val == '2'){
			$("#divQu").css("display", "none");
			$("input[type=radio][name=idpic][value='rbtnno']").attr("checked",true);  
		}else{
			$("#divQu").css("display", "inline");
			$("input[type=radio][name=idpic][value='rbtnyes']").attr("checked",true); 
		}
	}) 
});
function checkTelEnglish()
{ 
  if ($("#phone_mob").val() == "") { 
		  alert("请填写正确的手机电话号码");$("#phone_mob").focus(); return false; 
  }
  if($("#ddl_type").val() == '2'){//发货人
	  var newstr = $("#phone_mob").val().replace(/\-/g, "");
	  if(/^[0-9\\-]*$/.test($("#phone_mob").val()) == false){ alert("当前是发货人地址，手机/电话只能输入数字或者-横线，请正确输入");$("#phone_mob").focus(); return false; }
	  if(newstr.length < 10 || newstr.length > 13){ alert("当前是发货人地址，您输入的手机/电话的格式有误，请输入10-13位的手机/电话号码");$("#phone_mob").focus(); return false; }	  
  }else{ //收货人
      if(checkTel($("#phone_mob").val()) == false){ alert("当前是收货人地址，请输入中国地区正确的手机号码或者电话号码");$("#phone_mob").focus(); return false; }
  }

  return true;
}
function checkTel(value){
	var isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
	var isMob=/^((\+?86)|(\(\+86\)))?(13[0123456789][0-9]{8}|15[012356789][0-9]{8}|18[02356789][0-9]{8}|147[0-9]{8})$/;
	if(isMob.test(value)||isPhone.test(value)){
		return true;
	}else{
		return false;
	}
}
function check_phone(){
    return ($('[name="phone_tel"]').val() == '' && $('[name="phone_mob"]').val() == '');
}
function check_txtqu(){
	if ($('#divQu').css('display')=="inline"){
		return true;
	}else{
		return false;
	}
}
function hide_error(){
    $('#region').find('.error').hide();
}
function UploadCard(c_input,c_img){dialog("上传身份证","iframe:/data/fullAvatarEditor/upload_idphoto.php?box_height=450&box_width=580&avatar_sizes=550*347&c_input="+c_input+"&c_img="+c_img,"1250","630","");}
</script>
{include file=footer_member.html}